package com.coolingme.algo_01_list.lrucache;

/**
 * 缓存淘汰算法
 * LRU（Least recently used，最近最少使用）算法根据数据的历史访问记录来进行淘汰数据，
 * 其核心思想是“如果数据最近被访问过，那么将来被访问的几率也更高”。
 *
 * @author wangyue
 * @date 2020/11/6 15:30
 */
public class CacheNode {

    public Integer key;

    public String value;

    public CacheNode prev;

    public CacheNode next;

    public CacheNode(Integer key, String value) {
        this.key = key;
        this.value = value;
        this.prev = null;
        this.next = null;
    }

    @Override
    public String toString() {
        String result = this.key.toString();
        if (this.prev != null) {
            result += "(" + this.prev.key + ")";
        }
        result += "[" + this.value + "]";
        if (this.next != null) {
            result += " => " + this.next.toString();
        }
        return result;
    }
}
